<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class SendWechatEmail implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $message;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($message)
    {
      //
      $this->message = $message;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
      // 给楼主发送邮件
      // abort(404);  抛出异常时，任务就失败了
      $data = ['email'=>'lufeijun_1234@126.com', 'name'=>"吉鹏",'content'=>$this->message];
      \Mail::send('email.wechat.subscribe', $data, function($message) use($data)
      {
        $message->to($data['email'], $data['name'])->subject('微信通知');
      });
    }
}
